jQuery(document).ready(function(){
    jQuery("#study_id").on("click", function(event) {
        event.preventDefault();
        //alert("document.cookie: "+document.cookie);
        if (document.cookie ==null || document.cookie =="" || document.cookie == undefined){
            //alert("Cookie is null now, you will be redirected to login.");
            window.location.href="/login";
        }
        else{
            jQuery.ajax({
                scriptCharset: 'utf-8',
                type: "POST",
                url: "/study",
                contentType: "application/json",
                data: JSON.stringify({
                    "uid": document.cookie.split(';')[0].split('=')[1],
                    "phonenumber": document.cookie.split(';')[1].split('=')[1]
                }),
                dataType: "html",
                success: function(result) {
                    //alert("Validation Success");
                    window.location.href="/study";
                },
                error: function(error) {
                    //alert("Validation_islogin Erro");
                    window.location.href="/login";
                }
            });
        }
    });
});
